const path = require("path");
import vue from "@vitejs/plugin-vue";
import { defineConfig, loadEnv } from "vite";

export default ({ mode }) => {
  return defineConfig({
    resolve: {
      alias: { "/@": path.resolve(__dirname, "src") }
    },
    base: "./",
    plugins: [vue()],
    css: {
      preprocessorOptions: {
        less: {
          additionalData: '@import "./src/assets/less/public.less";' // 添加公共样式
        }
      }
    },
    build: {
      outDir: "car"
    },
    server: {
      host: "0.0.0.0",
      port: 3000,
      proxy: {
        "/security/v1/icardcOrder": "http://192.168.31.134:38080",
        "/security/v1/carAddress": "http://192.168.31.134:38080",
        "/security-server/v1": loadEnv(mode, process.cwd()).VITE_APP_BASE_URl,
        "/security/v1": loadEnv(mode, process.cwd()).VITE_APP_HMYD_URL,
        "/security/v2": loadEnv(mode, process.cwd()).VITE_APP_HMYD_URL,
        "/security/car": "http://192.168.31.134:38080"
      }
    }
  });
};
